package com.situ.mall.design.singleton;

//懒汉式 双重检查机制
//以时间换空间
public class Singleton3 {
    //懒汉式
    private static Singleton3 INSTANCE;

    private Singleton3() {
    }

    //线程安全问题
    public static Singleton3 getInstance() {
        if (INSTANCE == null) {// ==null 这种有线程安全的情况才去加锁
            synchronized (Singleton3.class) {
                if (INSTANCE == null) {
                    INSTANCE = new Singleton3();
                }
            }
        }
        return INSTANCE;
    }
}
